public class LoggingDecorator extends MachineDecorator {
    public LoggingDecorator(OldMachineInterface machine) {
        super(machine);
    }

    @Override
    public double getSensorData() {
        log("获取传感器数据");
        double data = super.getSensorData();
        log("传感器数据获取成功: " + data);
        return data;
    }

    @Override
    public void startEngine() {
        log("准备启动引擎");
        super.startEngine();
        log("引擎启动完成");
    }

    @Override
    public String getStatus() {
        log("获取设备状态");
        String status = super.getStatus();
        log("设备状态获取成功: " + status);
        return status;
    }

    private void log(String message) {
        System.out.println("[日志记录] " + System.currentTimeMillis() + " - " + message);
    }
}
